# ------------------------------------------------------------------------------------------------
### Generate Figure 1: Map of LGBTQ-free zones
# ------------------------------------------------------------------------------------------------

# Load data
load("../data/processed/LGBTQ_election_data.Rda")

# Define color scheme and labels for the map
map_colors <- c("transparent", "#D9534F")
map_labels <- c("No Resolution", "Anti-LGBTQ+ Resolution")

# Load and process municipality boundaries
PL_gmina <- gisco_get_lau(country = "PL", year="2020") %>%
  mutate(id = paste0(substr(LAU_ID, 5, 6), substr(LAU_ID, 10, nchar(LAU_ID)))) %>%
  left_join(
    LGBTQ_election_data %>% 
      select(id, any_level_any_type) %>% 
      unique(), 
    by = "id"
  )

# Generate map
ggplot(PL_gmina) +
  geom_sf(aes(fill = any_level_any_type)) +
  scale_fill_manual(
    values = map_colors,
    labels = map_labels
  ) +
  theme_map() +
  theme(
    legend.position = "bottom",
    legend.justification = c(.5),
    legend.title = element_blank(),
    text = element_text(size = 23)
  )

# Save the plot
ggsave("../output/plots/figure1.pdf", width = 14, height = 10, dpi = 700)
